package com.example.administrator.school.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.administrator.school.R;
import com.example.administrator.school.bean.MediaBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * ----------BigGod be here!----------/
 * ***┏┓******┏┓*********
 * *┏━┛┻━━━━━━┛┻━━┓*******
 * *┃             ┃*******
 * *┃     ━━━     ┃*******
 * *┃             ┃*******
 * *┃  ━┳┛   ┗┳━  ┃*******
 * *┃             ┃*******
 * *┃     ━┻━     ┃*******
 * *┃             ┃*******
 * *┗━━━┓     ┏━━━┛*******
 * *****┃     ┃神兽保佑*****
 * *****┃     ┃代码无BUG！***
 * *****┃     ┗━━━━━━━━┓*****
 * *****┃              ┣┓****
 * *****┃              ┏┛****
 * *****┗━┓┓┏━━━━┳┓┏━━━┛*****
 * *******┃┫┫****┃┫┫********
 * *******┗┻┛****┗┻┛*********
 * ━━━━━━神兽出没━━━━━━
 * 版权所有：个人
 * 作者：Created by a.wen.
 * 创建时间：2018/9/24
 * Email：13872829574@163.com
 * 内容描述：
 * 修改人：a.wen
 * 修改时间：${DATA}
 * 修改备注：
 * 修订历史：1.0
 */
public class FileAdapter extends BaseQuickAdapter<MediaBean, HomeAdapter.ViewHolder> {
    public FileAdapter(@Nullable List<MediaBean> data) {
        super(R.layout.layout_hot_content_itme, data);
    }

    @Override
    protected void convert(HomeAdapter.ViewHolder helper, MediaBean item) {
        Glide.with(mContext)
                .load(item.getPath())
//                .error(R.drawable.no_banner)
                .into(helper.mImg);
        helper.mTvTitle.setText(item.getName());
        helper.mTvContent.setText(item.getExtension());
        helper.mTvCreateTime.setText(TimeUtils.getFriendlyTimeSpanByNow(item.getUploadTime()));
        helper.mTvScanCount.setText(item.getId()+ "浏览");
//        //1,收费 不等于1,免费
//        if (item.getFree() == 1) {
//            helper.mImgVip.setVisibility(View.VISIBLE);
//            helper.mImgFree.setVisibility(View.GONE);
//        } else {
//            helper.mImgVip.setVisibility(View.GONE);
//            helper.mImgFree.setVisibility(View.VISIBLE);
//        }
    }


    static class ViewHolder extends BaseViewHolder {
        @Nullable
        @BindView(R.id.img)
        ImageView mImg;
        @Nullable
        @BindView(R.id.tv_title)
        TextView mTvTitle;
        @Nullable
        @BindView(R.id.tv_content)
        TextView mTvContent;
        @Nullable
        @BindView(R.id.tv_create_time)
        TextView mTvCreateTime;
        @Nullable
        @BindView(R.id.tv_scan_count)
        TextView mTvScanCount;
        @Nullable
        @BindView(R.id.img_vip)
        ImageView mImgVip;
        @Nullable
        @BindView(R.id.tv_share_count)
        TextView mTvShareCount;
        @Nullable
        @BindView(R.id.img_free)
        ImageView mImgFree;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}